package model.parseTree;

import model.searchers.ISearcher;
import model.searchers.URLList;


/**
 * Class SearchNode is a superclass representing a search node in a syntax tree.
 * The node maintains a value and two child nodes.
 */
// class is declared abstract to avoid instances of the class to be created
public abstract class SearchNode {
	private SearchNode leftChild;
	private SearchNode rightChild;
	private String value;

	/**
	 * Constructor of SearchNode
	 * 
	 * @param leftChild		the left child node
	 * @param rightChild	the right child node
	 * @param value			the string value of the node
	 */
	public SearchNode(SearchNode leftChild, SearchNode rightChild, String value) {
		this.leftChild = leftChild;
		this.rightChild = rightChild;
		this.value = value;
	}
	
	/**
	 * Get result of evaluating the node
	 * @param searcher	searcher to search with
	 * @return URLList of results
	 */
	public abstract URLList getResult(ISearcher searcher);

	/**
	 * @return the left child node
	 */
	public SearchNode getLeft() {
		return leftChild;
	}

	/**
	 * @return the right child node
	 */
	public SearchNode getRight() {
		return rightChild;
	}

	/**
	 * @return the value of the node
	 */
	public String getValue() {
		return value;
	}

	/**
	 * Set the left child node to the specified node
	 * 
	 * @param newLeft	a node to be set as new left child
	 */
	public void setLeft(SearchNode newLeft) {
		this.leftChild = newLeft;
	}

	/**
	 * Set the right child node to the specified node
	 * 
	 * @param newLeft	a node to be set as new right child
	 */
	public void setRight(SearchNode newRight) {
		this.rightChild = newRight;
	}


}
